package top.fullj.fsm;

import com.google.common.base.Preconditions;

/**
 * @author bruce.wu
 * @since 2021/8/2 10:27
 */
public class State {

    private final String name;

    public State(String name) {
        Preconditions.checkNotNull(name);
        this.name = name;
    }

    @Override
    public int hashCode() {
        return name.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        State state = (State) o;
        return name.equals(state.name);
    }

    @Override
    public String toString() {
        return name;
    }

    void enter(StateMachine fsm) {}

    void leave(StateMachine fsm) {}

}
